package show.me.the.money.util.exp.standard;

import java.util.List;

import show.me.the.money.util.PyConverter;
import show.me.the.money.util.context.Context;
import show.me.the.money.util.exp.ExpRunner;
import show.me.the.money.util.exp.ExpSymbols;
import show.me.the.money.util.exp.Expression;

@SuppressWarnings("unchecked")
public class PY extends Expression {

	public PY() {
		symbol = ExpSymbols.PY;
	}

	public String run(List lsExp, Context ctx) {
		try {
			List la = (List)lsExp.get(1);
			String s = (String)ExpRunner.run(la, ctx);
			return PyConverter.getFirstLetter(s);
		} 
		catch (Exception e) {
			logger.fatal("run JSONException:", e);
		}
		return "";
	}

	public String toString(List lsExp, Context ctx) {
		try {
			List la = (List)lsExp.get(1);
			String s = ExpRunner.toString(la, ctx);
			return symbol + "(" + s + ")";
		} 
		catch (Exception e) {
			logger.fatal("run JSONException:", e);
		}
		return symbol + "()";
	}

}
